﻿using System;
using System.Threading;

namespace Universe.Cache.Tests
{
    class Program
    {
        static void Main(string[] args)
        {

            MyEnvironment.Instance.CreateStressDB(50, 1);

            SampleThread.CancelToken cancel = new SampleThread.CancelToken();
            ManualResetEvent run = new ManualResetEvent(false);
            SampleThread t1 = new SampleThread(cancel, 1, run);
            SampleThread t2 = new SampleThread(cancel, 2, run);

            ThreadPool.QueueUserWorkItem(state => t1.RunReader(0, 0, false));
            ThreadPool.QueueUserWorkItem(state => t2.RunWriter(false));

            run.Set();
            Thread.Sleep(TimeSpan.FromSeconds(10));
            cancel.IsCanceled = true;

            t1.Done.WaitOne();
            t2.Done.WaitOne();

        }
    }
}
